﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProcessLoads.aspx.cs" Inherits="PerformanceReport.ProcessLoads" %>

<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self"></base>
    <title>流程负载统计</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="CSS/reportCss.css" rel="stylesheet" type="text/css" />
    <script src="JS/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="JavaScript/highcharts.js" type="text/javascript"></script>
    <script src="JavaScript/modules/exporting.js" type="text/javascript"></script>
    <script src="JS/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" charset="utf-8"></script>
    <script type="text/javascript">
        var Json;   //全局变量，用于接收返回值
        var ProcessStep;
        var FinishQty;
        var UnFinishQty;
        var Nae;


        $(function () {
            var chart;

            GetJason();
            var i = 0;
            //初始化获取Jason对象值
            var ProcessName = document.getElementById("drpProcessName");
            //判断页面上选择了流程名时执行该方法
            if (ProcessName.selectedIndex > 0) {
                if (Json != undefined) {         //判断返回值不等于空
                    $.each(Json, function (i, item) {
                        ProcessStep = (i, item.ProcessStep);
                        FinishQty = (i, item.FinishQty);
                        UnFinishQty = (i, item.UnFinishQty);
                        i++;
                    });
                }
            }

            $(document).ready(function () {
                //chart = new Highcharts.Chart({
                var options = {
                    chart: {
                        renderTo: 'container'
                    },
                    title: {
                        //text: 'Combination chart'
                        text: ''
                    },
                    xAxis: {
                        //categories: ['a', 'b', 'c', 'd', 'e']
                        categories: []
                    },
                    credits:       //去掉有效右下角的Highcharts.com的标志
                    {
                    href: '',
                    text: ''
                },
                tooltip: {
                    formatter: function () {
                        var s;
                        if (this.point.name) { // the pie chart
                            s = '' +
                            this.point.name + ': ' + this.y + ' fruits';
                        } else {
                            s = '' +
                            this.x + ': ' + this.y;
                        }
                        return s;
                    }
                },
                //series: [{
                //type: 'column',
                //name: '待办数量',
                ////data: []
                //data: [2, 3, 4, 5, 1,2,2,2,2,2,2,2,2,2,2,2]
                //}, {
                //type: 'column',
                //name: '完成数量',
                ////data: []
                //data: [6, 7, 8, 9, 1,1,1,1,1,1,1,1,1,1,1,1]
                //}]

                series: []

            };

           // alert(ProcessStep);
            //将流程步骤名添加到图表中
            var ProcessName = document.getElementById("drpProcessName");
            //alert(ProcessName.selectedIndex);
            //判断页面上选择了流程名时执行该方法
            if (ProcessName.selectedIndex > 0) {
                if (ProcessStep != undefined) {     //判断返回值不等于空
                    var arr = new Array();
                    arr = ProcessStep.split(",");
                    $.each(arr, function (index, value) {
                        //StrSub += "'" + value + "',";
                        options.xAxis.categories.push(value);   //将流程步骤名添加到图表中
                        //alert(value[0]);
                    });
                }
            }
            //alert(arr);

            //完成数量统计
            var ProcessName = document.getElementById("drpProcessName");
            //判断页面上选择了流程名时执行该方法
            if (ProcessName.selectedIndex > 0) {    
                if (FinishQty != undefined) {     //判断返回值不等于空
                    var strSub = FinishQty.replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'");
                    //alert(strSub);
                    strSub = eval("(" + strSub + ")");
                    options.series.push(strSub);  //添加
                }
            }

            //待办数量统计
            var ProcessName = document.getElementById("drpProcessName");
            //判断页面上选择了流程名时执行该方法
            if (ProcessName.selectedIndex > 0) {
                if (UnFinishQty != undefined) {       //判断返回值不等于空
                    var strSubData = UnFinishQty.replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'").replace("#dan#", "'");
                    //alert(strSubData);
                    strSubData = eval("(" + strSubData + ")");
                    options.series.push(strSubData);   //添加
                }
            }

            //创建新的统计图表
            var chart = new Highcharts.Chart(options);
        });

    });


        function GetJason() {
            $.ajaxSetup({ async: false });
            var drpBu = $("#drpProcessName").val();
            var VarStartTime = $("#txtStart").val();
            var VarEndTime = $("#txtEnd").val();
            //alert(drpBu);
            $.get("AjaxPage/GenerateLoadsReports.ashx", { Para: drpBu, StartDate: VarStartTime, EndDate: VarEndTime }, function (data) {
                var arr = eval(data);                
                Json = arr; 
            })

        }
    </script>
    <script type="text/javascript">         
        function checkInfo() {
            var ProcessName = document.getElementById("drpProcessName");
            //alert(ProcessName.selectedIndex);
            if (ProcessName.selectedIndex) {
                return true;
            } else {
                alert("请按流程名查询！");
                return false;
            }
            var rdio = document.getElementById("Radio2").checked = "checked";     //设置数据报表为选中状态
        }

        //重置查询条件为初始状态
        function check() {
            var rdio = document.getElementById("Radio2").checked = "checked";   //设置数据报表为选中状态
            var ProcessName = document.getElementById("drpProcessName");
            ProcessName.selectedIndex = 0;
            document.getElementById("txtStart").value = "";
            document.getElementById("txtEnd").value = "";
        }
    </script>
    <script type="text/javascript">
        function SetDiv(ee) {
            if (ee == "1") {
                $("#divList").css("display", "none");
                $("#container").css("display", "block");
            } else {
                $("#divList").css("display", "block");
                $("#container").css("display", "none");
            }
        }

    </script>
</head>
<body style="padding-left: 15px">
    <form id="form1" runat="server">
    <div class="divHead" style="padding-top: 10px">
        <span style="font-weight: bold; font-size: 25px">
            流程负载统计</span>
    </div>
    <div id="divCondition" runat="server" class="div_default_condition" style="padding-top: 10px">
        <fieldset>
            <legend style="font-size: 18px"><%--查询条件--%></legend>
            <table>
                <tr>
                    <td>
                        统计周期：&nbsp;<span style="color: Red">*</span>
                    </td>
                    <td>
                        开始时间
                        <asp:TextBox ID="txtStart" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                            runat="server"></asp:TextBox>
                    </td>
                    <td>
                        结束时间
                        <asp:TextBox ID="txtEnd" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                            runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <span style=" color:Red">特别提示：由于流程历史数据过大，统计周期建议控制为三个月内。</span> 
                    </td>
                </tr>
                <tr>
                    <td>
                        流程名：&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: Red">*</span>
                    </td>
                    <td style="padding-left: 53px;">
                        <asp:DropDownList ID="drpProcessName" runat="server" />
                    </td>
                    <td style="padding-left: 53px;">
                        <asp:Button ID="btnSearch" runat="server" CssClass="btn-primary" Text="查 询" OnClick="btnSearch_Click"
                            OnClientClick="return checkInfo()" />
                        <input id="btnReset" type="button" class="btn-primary" value="重 置" onclick="check()" />
                    </td>
                </tr>
                  <tr>
                    <td>
                        报表类型：
                    </td>
                    <td>
                        <%-- <asp:RadioButtonList ID="rbReportType" runat="server" RepeatDirection="Horizontal"
                        TextAlign="Right">
                        <asp:ListItem Value="1" Text="图形报表" OnClick="SetDiv(this.value)"></asp:ListItem>
                        <asp:ListItem Value="2" Text="数据报表" OnClick="SetDiv(this.value)" Selected="True"></asp:ListItem>
                    </asp:RadioButtonList>--%>
                        <input id="Radio1" type="radio" name="CheckType" value="1" onclick="SetDiv(this.value)" />图形报表
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <input id="Radio2" type="radio" name="CheckType" value="2" checked="checked" onclick="SetDiv(this.value)" />数据报表
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>     
    <div id="divList">
        <table width="99.5%" cellspacing="1" cellpadding="5" style="margin-left: 2px" border="1"
            bordercolor="#ccc">
            <tr>
               <%-- <th style="width: 5%">
                    序号
                </th>--%>
                <th style="width: 20%">
                    流程名称
                </th>
                <th style="width: 8%">
                    步骤名称
                </th>
            </tr>
            <tbody>
                <asp:Repeater ID="rpSource" runat="server">
                    <ItemTemplate>
                        <tr onmouseover="currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F3F3F3';"
                            onmouseout="this.style.backgroundColor=currentcolor;" style='background-color: <%# (Container.ItemIndex + 1)%2==0?"#F9F9F9":"" %>;
                            cursor: pointer;'>
                            <%--<td>
                                <%#Container.ItemIndex+1 %>
                            </td>--%>
                            <td>
                                <%#Eval("ProcessName")%>
                            </td>
                             <%#InitLine() %>                            
                            
                        </tr>
                        <tr>
                            <td>
                                完成
                            </td>
                            <%#TotalFinishQty()%>
                        </tr>
                         <tr>
                            <td>
                                待办
                            </td>
                            <%#TotalUnFinishQty()%>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
            <%--<tr>
                <td colspan="19" style="text-align: left; padding: 5px;">
                    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoHTML="Count %RecordCount%"
                        HorizontalAlign="left" Width="100%" CssClass="aspNetPager" OnPageChanged="AspNetPager1_PageChanged"
                        PageSize="10" AlwaysShow="true" SubmitButtonStyle="display:none" InputBoxStyle="display:none"
                        NextPageText="下一页" FirstPageText="首页" LastPageText="末页" PrevPageText="上一页">
                    </webdiyer:AspNetPager>
                </td>
            </tr>--%>
        </table>
    </div>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
    </div>
    </form>
</body>
</html>
